var status = 0;

function start() {
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0 && status == 0) {
			cm.dispose();
			return;
		}
		if (mode == 1)
			status++;
		else
			status--;
		if (status == 0) {
			cm.sendSimple("Hello #h #, Welcome to #rChickenMS!#k\r\nWhat do you want to do?\r\n#L1##bTrade #i4000422# for 1k NX#l\r\n#L2##bTrade #i4000423# for 2.5k NX#k#l\r\n#L3##bTrade #i4000424# for 5k NX#k#l\r\n#L4##bTrade #i4000425# for 10k NX#k#l\r\n#L5##bI have way too much mesos O.o#k#l\r\n#L6##eEww, you are ugly, i won't talk to you!#n#l");
		} else if (status == 1) {
			if (selection == 1) {
				if (cm.itemQuantity(4000422) >= 1 ) {
					cm.gainItem(4000422, -1);				
					cm.gainNX(1000);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #i4000422#\r\nDon't scam me or I will use this on you! #s5001001#");
					cm.dispose();
				}								
			} else if (selection == 2) {
				if (cm.itemQuantity(4000423) >= 1 ) {
					cm.gainItem(4000423, -1);				
					cm.gainNX(2500);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #i4000423#\r\nDon't scam me or I will use this on you! #s5001001#");
					cm.dispose();
				}
			} else if (selection == 3) {
				if (cm.itemQuantity(4000424) >= 1 ) {
					cm.gainItem(4000424, -1);				
					cm.gainNX(5000);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #i4000424#\r\nDon't scam me or I will use this on you! #s5001001#");
					cm.dispose();
				}
			} else if (selection == 4) {
				if (cm.itemQuantity(4000425) >= 1 ) {
					cm.gainItem(4000425, -1);				
					cm.gainNX(10000);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough #i4000425#\r\nDon't scam me or I will use this on you! #s5001001#");
					cm.dispose();
				}
			} else if (selection == 5) {
				cm.sendSimple("Ooh! i know that problem\r\n\r\n#L1##bI want to trade 1bil mesos for 1 #i4031476##l\r\n#L2#I want to trade 1 #i4031476# for 1bil mesos#k#l");
			} else {
				cm.sendOk("Oh. i see... Well then, have fun in #rChickenMS!#k\r\n\r\n#e*cries*#n");
				cm.dispose();
			}
		} else {
			if (selection == 1) {
				if (cm.getMeso() >= 1000000000) {
					cm.gainMeso(-1000000000);
					cm.gainItem(4031476, 1);
					cm.dispose();
				} else {
					cm.sendOk("You don't have enough mesos!");
					cm.dispose();
				}
			} else {
				if (cm.itemQuantity(4031476) >= 1) {
					if (cm.getMeso() >= 1147483648) {
						cm.sendOk("You have way too much mesos\r\nI cant give you 1 bil");
						cm.dispose();
					} else {
						cm.gainItem(4031476, -1);
						cm.gainMeso(1000000000);
						cm.dispose();
					}
				} else {
					cm.sendOk("You don't have a #i4031476#");
					cm.dispose();
				}
			}
		}
	}
}